package com.example.serviceorder.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.example.serviceorder.mode.Order;
import org.example.dubbo.api.mode.UserInfo;
import org.example.dubbo.api.service.UserService;
import org.omg.CORBA.ORB;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Reference
    private UserService userService;

    @GetMapping("/{id}")
    public Order get(@PathVariable Long id){
        UserInfo userInfo = userService.get(1l);
        Order order = new Order();
        order.setId(id);
        order.setUserId(userInfo.getId());
        order.setUserName(userInfo.getName());
        return order;
    }
}
